package com.rytong.tools.ui;

import com.rytong.tools.ui.LPSelect;
import android.app.Dialog;
import android.content.Context;
import android.view.KeyEvent;
import android.view.View;

/**
 * @author Chris
 * 
 */
public class LPAlertDialog extends Dialog {
    // 容器标记，一般由lua脚本指定
    private int tag_;
    private String title_;
    // dialog里装载的view
    public View view_;
    // dialog里装在的component
    public Component comp_;

    /**
     * @param context
     * @param dialog
     */
    public LPAlertDialog(Context context, int theme, View view) {
        super(context, theme);
        // 设置在Dialog外任意区域点击关闭Dialog
        setCanceledOnTouchOutside(true);
        view_ = view;
        title_ = "";
    }

    /*
     * (non-Javadoc)
     * 
     * @see android.app.Dialog#onKeyDown(int, android.view.KeyEvent)
     */
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            if (isShowing()) {
                LPSelect.ISPOPING = false;
            }
            return super.onKeyDown(keyCode, event);
        default:
            return super.onKeyDown(keyCode, event);
        }
    }

    public void setTag(int tag) {
        tag_ = tag;
    }

    public int getTag() {
        return tag_;
    }

    public void dismiss() {
        super.dismiss();
    }

    public void setTitle(String title) {
        title_ = title;
        super.setTitle(title);
    }

    public String getTitle() {
        return title_;
    }
    
    public void setComponent(Component comp){
        comp_ = comp;
    }
}
